<template>
  <div style="padding-top:30px" id="app">
    <div  style="margin-left:100px;font-size:30px" id="nav">
      <div style="float: left;">
        <router-link to="/">首页</router-link> |
        <router-link to="/list">列表</router-link> |
        <router-link v-if="!name" to="/login">登录</router-link>
      </div>
      <div v-if="name" style="float: left;">
        <!-- <p style="float: left">召唤师：</p> -->
        <router-link to="#">召唤师：<span>{{name}}</span></router-link>
        <button @click="ele">退出</button>
      </div>
    </div>
    <div class="clear"></div>
    <router-view/>
  </div>
</template>
<script>
export default {
  data(){
    return {
      name:''
    }
  },
  methods:{
    ele(){
      localStorage.removeItem('name');
      this.$router.push('/login');
      window.location.reload()
    }
  },
  mounted(){
    this.name=localStorage.getItem('name');
  }
}
</script>
<style>
#nav a {
  font-weight: bold;
  color: #2c3e50;
}

#nav a.router-link-exact-active {
  color: #42b983;
}
.clear{
  clear: both;
}
</style>
